from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

from chatbot.service.init.bot_initialize import BotFactory
from chatbot.settings import logger


class ChatBotAppConfig(AppConfig):
    name = 'chatbot'
    verbose_name = _("chatbot")

    def ready(self):
        try:
            bots = BotFactory()
            bots.init()
            logger.info('ChatBot Initial Successful')
        except Exception as e:
            logger.info('ChatBot Initial Failed')
            logger.error(e, exc_info=True)
